# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.53 or later)
# using gcc 2.95.4 (or later).
# You may look at <URL:http://hard-mofo.dsvr.net/gcc/> for an up-to-date
# gcc port.

CC   = gcc -mlibscl
BIND = $(CC)
AS   = $(CC) -c
ASM  = as
SQUEEZE = squeeze -v
E    =

# flags
#   CFLAGS    flags for C compile
#   LFLAGS1   flags after output file spec, before obj file list
#   LFLAGS2   flags after obj file list (libraries, etc)
#
LIB      =
CFLAGS   = -O2 -mthrowback -DNO_STRNICMP
ASMFLAGS = -throwback -objasm -upper
LFLAGS1  =
LFLAGS2  = $(LIB)

# object file lists
OBJS1 = o.unzip o.crc32 o.crypt o.envargs o.explode
OBJS2 = o.extract o.fileio o.globals o.inflate o.list o.match
OBJS3 = o.process o.ttyio o.unreduce o.unshrink o.zipinfo
OBJS  = $(OBJS1) $(OBJS2) $(OBJS3) o.riscos o.swiven o.acorn
OBJF  = o.funzip o.crc32 o.cryptf o.globalsf o.inflatef o.ttyiof \
	o.riscos o.swiven
OBJX  = o.unzipsfx o.crc32  o.crypt_ o.extract_ o.fileio_ o.globals_ \
	o.inflate_ o.match_ o.process_ o.ttyio_ o.acorn_ o.swiven o.riscos_

UNZIP_H = h.unzip h.unzpriv h.globals acorn.h.riscos acorn.h.swiven

all:	  unzip funzip unzipsfx


install:  unzip funzip unzipsfx
	$(SQUEEZE) unzip %.unzip
	$(SQUEEZE) funzip %.funzip
	$(SQUEEZE) unzipsfx unzipsfx
	copy %.unzip %.zipinfo ~CVF

# rules for unzip and funzip
o.crc32:	c.crc32 $(UNZIP_H) h.zip h.crc32
	$(CC) $(CFLAGS) -c c.crc32 -o o.crc32
o.crypt:	c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
	$(CC) $(CFLAGS) -c c.crypt -o o.crypt
o.envargs:	c.envargs $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.envargs -o o.envargs
o.explode:	c.explode $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.explode -o o.explode
o.extract:	c.extract $(UNZIP_H) h.crc32 h.crypt
	$(CC) $(CFLAGS) -c c.extract -o o.extract
o.fileio:	c.fileio $(UNZIP_H) h.crc32 h.crypt h.ttyio h.ebcdic
	$(CC) $(CFLAGS) -c c.fileio -o o.fileio
o.funzip:	c.funzip $(UNZIP_H) h.crc32 h.crypt h.ttyio
	$(CC) $(CFLAGS) -c c.funzip -o o.funzip
o.globals:	c.globals $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.globals -o o.globals
o.inflate:	c.inflate h.inflate $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.inflate -o o.inflate
o.list:		c.list $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.list -o o.list
o.match:	c.match $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.match -o o.match
o.process:	c.process $(UNZIP_H) h.crc32
	$(CC) $(CFLAGS) -c c.process -o o.process
o.ttyio:	c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
	$(CC) $(CFLAGS) -c c.ttyio -o o.ttyio
o.unreduce:	c.unreduce $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.unreduce -o o.unreduce
o.unshrink:	c.unshrink $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.unshrink -o o.unshrink
o.unzip:	c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
	$(CC) $(CFLAGS) -c c.unzip -o o.unzip
o.zipinfo:	c.zipinfo $(UNZIP_H)
	$(CC) $(CFLAGS) -c c.zipinfo -o o.zipinfo

o.crypt_:	c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
	$(CC) $(CFLAGS) -DSFX -c c.crypt -o o.crypt_
o.extract_:	c.extract $(UNZIP_H) h.crc32 h.crypt
	$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
o.fileio_:	c.fileio $(UNZIP_H) h.crc32 h.crypt h.ttyio h.ebcdic
	$(CC) $(CFLAGS) -DSFX -c c.fileio -o o.fileio_
o.globals_:	c.globals $(UNZIP_H)
	$(CC) $(CFLAGS) -DSFX -c c.globals -o o.globals_
o.inflate_:	c.inflate h.inflate $(UNZIP_H) h.crypt
	$(CC) $(CFLAGS) -DSFX -c c.inflate -o o.inflate_
o.match_:	c.match $(UNZIP_H)
	$(CC) $(CFLAGS) -DSFX -c c.match -o o.match_
o.process_:	c.process $(UNZIP_H) h.crc32
	$(CC) $(CFLAGS) -DSFX -c c.process -o o.process_
o.ttyio_:	c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
	$(CC) $(CFLAGS) -DSFX -c c.ttyio -o o.ttyio_

o.unzipsfx:	c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
	$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx

o.cryptf:	c.crypt $(UNZIP_H) h.zip h.crypt h.crc32 h.ttyio
	$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.cryptf
o.globalsf:	c.globals $(UNZIP_H)
	$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globalsf
o.inflatef:	c.inflate h.inflate $(UNZIP_H) h.crypt
	$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflatef
o.ttyiof:	c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
	$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyiof

o.acorn:	acorn.c.acorn $(UNZIP_H)
	$(CC) $(CFLAGS) -I@ -c acorn.c.acorn
o.acorn_:	acorn.c.acorn $(UNZIP_H)
	$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.acorn_ acorn.c.acorn

o.riscos:	acorn.c.riscos $(UNZIP_H)
	$(CC) $(CFLAGS) -I@ -c acorn.c.riscos
o.riscos_:	acorn.c.riscos $(UNZIP_H)
	$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.riscos_ acorn.c.riscos

o.swiven:	acorn.s.swiven
	$(ASM) $(ASMFLAGS) acorn.s.swiven -o o.swiven

unzip:	  $(OBJS)
	  $(BIND) -o unzip$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
funzip:	  $(OBJF)
	  $(BIND) -o funzip$(E) $(LFLAGS1) $(OBJF) $(LFLAGS2)
unzipsfx: $(OBJX)
	  $(BIND) -o unzipsfx$(E) $(LFLAGS1) $(OBJX) $(LFLAGS2)

clean:
	remove unzip
	remove funzip
	remove zipinfo
	remove unzipsfx
	create o.!fake! 0
	wipe o.* ~cf

# end of Makefile
